package com.quick.develop.flowable.controller.process;

import com.alibaba.fastjson.JSONObject;
import com.quick.develop.framework.common.page.R;
import com.quick.develop.flowable.domain.rule.BpmExampleRule;
import com.quick.develop.flowable.service.process.IBpmExampleRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@Api(tags = "管理后台 - 流程预设值规则")
@RestController
@RequestMapping("/proc-example-rule")
@Validated
public class BpmExampleRuleController {

    @Autowired
    private IBpmExampleRuleService bpmExampleRuleService;



    @PostMapping("/getRules")
    @ApiOperation(value = "获取流程规则")
    public R<?> getBpmExampleRule(@RequestBody BpmExampleRule bpmExampleRule){
        return R.ok(bpmExampleRuleService.getBpmExampleRule(bpmExampleRule));
    }



    @PostMapping("/addRules")
    @ApiOperation(value = "新增规则")
    public R<?> addBpmExampleRule(@RequestBody BpmExampleRule bpmExampleRule){

        return R.ok(bpmExampleRuleService.addBpmExampleRule(bpmExampleRule));
    }

    @PostMapping("/creatNewRule")
    @ApiOperation(value = "复制一份新的规则")
    public R<String> creatNewRule(@RequestBody Map<String,String> map){

        return R.ok(bpmExampleRuleService.creatNewRule(map));
    }

    @PostMapping("/isHashCurent")
    @ApiOperation(value = "判断某个节点是否存在当前用户,若是存在返回此节点")
    public R<String> isHashCurent(@RequestBody Map<String,String> map){

        return R.ok(bpmExampleRuleService.isHashCurent(map));
    }
    @PostMapping("/getNodeCode")
    @ApiOperation(value = "获取某个节点的预设值分配规则")
    public R<JSONObject> getNodeCode(@RequestBody Map<String,String> map){
        return R.ok(bpmExampleRuleService.getNodeCode(map));
    }

    @PostMapping("/updateNodeCode")
    @ApiOperation(value = "设置某个节点的预设值分配规则")
    public R<String> updateNodeCode(@RequestBody Map<String,String> map){
        return R.ok(bpmExampleRuleService.updateNodeCode(map));
    }

    @PostMapping("/checkRequired")
    public R<String> checkRequired(@RequestBody Map<String,Object> map){

        return R.ok(bpmExampleRuleService.checkRequired(map));
    }
}
